from django.db import models

class Ingredient(models.Model):
    """
    An Ingredient is a certain amount of a substance.
    """
    amount=models.FloatField()
    UNITS_CHOICES=(
        ('g','grams'),
        ('oz','dry ounces'),
        ('cups','US cups',)
        )
    units=models.CharField(choices=UNITS_CHOICES, max_length=10)
    add_time=models.CharField(max_length=500)
    substance=models.ForeignKey('Substance')

class Recipe(models.Model):
    ingredient=models.ManyToManyField(Ingredient)

class Substance(models.Model):
    name=models.CharField(max_length=500)
    alpha_acid_percent=models.FloatField(blank=True, null=True)

class Brew(models.Model):
    recipe=models.ForeignKey(Recipe)
    name=models.CharField(max_length=500)

class Container(models.Model):
    purchased_on=models.DateTimeField(blank=True, null=True)
    CONTAINER_CHOICES=(
        ('carboy','carboy'),
        ('bucket','food-grade bucket'),
        )
    description=models.CharField(max_length=100, choices=CONTAINER_CHOICES)
    capacity=models.FloatField(blank=True, null=True)

class Action(models.Model):
    ACTION_CHOICES=(
        ('transferred_to','transferred_to'),
        ('transferred_from','transferred_from'),
        ('checked_gravity','checked_gravity'),
        ('brewed','brewed'),
        ('bottled','bottled'),
        )
    action=models.CharField(max_length=100, choices=ACTION_CHOICES)
    fermenter=models.ForeignKey(Container)
    gravity=models.FloatField(blank=True, null=True)
    when=models.DateTimeField()
    brew=models.ForeignKey(Brew)
    comments=models.TextField()



